package com.sahala.downimage.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;

import com.sahala.downimage.dao.IImageDAO;
import com.sahala.downimage.domain.ImageDO;
import com.sahala.downimage.domain.ImageQueryDO;

public class ImageDAOImpl implements IImageDAO {
	
	@Autowired
	public SqlSessionTemplate sqlSession;

	@Override
	public int save(ImageDO image){
		return sqlSession.insert("ImageDAO.save", image);
	}
	
	public List<ImageDO> queryAll(ImageQueryDO query){
		return sqlSession.selectList("ImageDAO.queryAll", query);
	}

	@Override
	public int deleteById(int id) {
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("id", id);
		return sqlSession.delete("ImageDAO.deleteById",params);
	}

}
